#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_SIMPLE
#define D2D_REQUIRES_SCENE_POSITION
#include "d2d1effecthelpers.hlsli"

//水平波长
float wavelengthX;
// 水平波幅
float amplitudeX;
//垂直波长
float wavelengthY;
//垂直波幅
float amplitudeY;

float2 size;

D2D_PS_ENTRY(main) {

    //当前位置
    float2 cPoint = D2DGetScenePosition().xy;
    
    float hox = amplitudeX*size.x;
    float voy = amplitudeY*size.y;

    float xwl = wavelengthX *size.x;
    float ywl = wavelengthY*size.y;
    
    // float hox = size.x;
    // float voy = size.y;

    // float xwl = size.x;
    // float ywl = size.y;

    float nx ;
    float ny ;
    nx = cPoint.y/xwl;
    ny = cPoint.x/ywl;
    if(xwl==0){
        nx = 0;
    }
    if(ywl==0){
        ny =0;
    }



    float fx = sin(nx);
    float fy = cos(ny);
    float ox = cPoint.x+hox*fx;
    float oy = cPoint.y+voy*fy;
    if(ox>size.x||ox<0||oy>size.y||oy<0){
        return float4(0,0,0,0);
    }
    float4 color=D2DSampleInputAtPosition(0,float2(ox,oy));
    return color;
    // float4 color = D2DGetInput(0);
    // float2 uv = D2DGetScenePosition().xy;
    // float g = uv.x;
    // return float4(g,g,g,color.a);
}



